We now run fully through ASAN here.
Closes: #609
Approved by: jlebon
g_output_stream_close (out, NULL, NULL);
/* Now generate NEW_GENERATED from OLD and OUT. */
- in = g_memory_input_stream_new_from_bytes (g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out)));
+ { g_autoptr(GBytes) bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out));
+ in = g_memory_input_stream_new_from_bytes (bytes);
+ }
bspatch_stream.read = bzpatch_read;
bspatch_stream.opaque = in;
static void
helper_test_compress_decompress (const guint8 *data, gssize data_size)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_autoptr(GOutputStream) out_compress = g_memory_output_stream_new_resizable ();
g_autoptr(GOutputStream) out_decompress = NULL;
g_autoptr(GInputStream) in_compress = g_memory_input_stream_new_from_data (data, data_size, NULL);
{
gssize n_bytes_written;
g_autoptr(GInputStream) convin = NULL;
- g_autoptr(GConverter) decompressor = (GConverter*)_ostree_lzma_decompressor_new ();
+ g_autoptr(GConverter) decompressor = (GConverter*)_ostree_lzma_decompressor_new ();
+ g_autoptr(GBytes) bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out_compress));
- in_decompress = g_memory_input_stream_new_from_bytes (g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out_compress)));
+ in_decompress = g_memory_input_stream_new_from_bytes (bytes);
convin = g_converter_input_stream_new ((GInputStream*) in_decompress, decompressor);
n_bytes_written = g_output_stream_splice (out_decompress, convin,
G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET | G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
g_autoptr(GPtrArray) split_path = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
const char *pathname = "/foo/bar/baz";
const char *checksum = "01234567890123456789012345678901";
g_autofree char *source_checksum = NULL;
g_assert_false (ostree_mutable_tree_lookup (tree, "bar", &source_checksum2,
&source_subdir2, &error));
+ g_clear_error (&error);
}
static void
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
const char *dirname = "foo";
const char *filename = "bar";
const char *checksum = "01234567890123456789012345678901";
g_assert (ostree_mutable_tree_replace_file (tree, filename, checksum, &error));
g_assert_false (ostree_mutable_tree_ensure_dir (tree, filename, &parent, &error));
+ g_clear_error (&error);
}
static void
test_replace_file (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
const char *filename = "bar";
const char *checksum = "01234567890123456789012345678901";
const char *checksum2 = "ABCDEF01234567890123456789012345";
const char *subdir_checksum = "ABCD0123456789012345678901234567";
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *subdir = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert_null (ostree_mutable_tree_get_contents_checksum (tree));
ostree_mutable_tree_set_contents_checksum (tree, checksum);
static void
test_ot_util_usage_error (void)
{
- GError *error = NULL;
- GOptionContext *context = g_option_context_new ("[TEST]");
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GOptionContext) context = g_option_context_new ("[TEST]");
GPrintFunc old_printerr = g_set_printerr_handler (util_usage_error_printerr);
ot_util_usage_error (context, "find_me", &error);
g_assert_nonnull (strstr (printerr_str->str, "[TEST]"));
g_assert_nonnull (strstr (error->message, "find_me"));
+ g_clear_error (&error);
g_set_printerr_handler (old_printerr);
g_string_free (printerr_str, TRUE);
printerr_str = NULL;
- g_option_context_free (context);
}
int main (int argc, char **argv)
static void
test_ot_parse_boolean (void)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gboolean out = FALSE;
g_assert_true (ot_parse_boolean ("yes", &out, &error));
g_assert_true (out);
out = TRUE;
g_assert_true (ot_parse_boolean ("none", &out, &error));
g_assert_false (out);
+ g_clear_error (&error);
g_assert_false (ot_parse_boolean ("FOO", &out, &error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
+ g_clear_error (&error);
}
static void
test_ot_parse_keyvalue (void)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
char *keyvalue[] = {"foo=bar", "a=", "b=1231231"};
char *key[] = {"foo", "a", "b"};
char *value[] = {"bar", "", "1231231"};
&out_value,
&error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
+ g_clear_error (&error);
}
}
static void
test_ot_util_filename_validate (void)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
/* Check for valid inputs. */
g_assert (ot_util_filename_validate ("valid", &error));
+ g_assert_no_error (error);
g_assert (ot_util_filename_validate ("valid_file_name", &error));
+ g_assert_no_error (error);
g_assert (ot_util_filename_validate ("file.name", &error));
+ g_assert_no_error (error);
g_assert (ot_util_filename_validate ("foo..", &error));
+ g_assert_no_error (error);
g_assert (ot_util_filename_validate ("..bar", &error));
+ g_assert_no_error (error);
g_assert (ot_util_filename_validate ("baz:", &error));
+ g_assert_no_error (error);
/* Check for invalid inputs. */
g_assert_false (ot_util_filename_validate ("not/valid/file/name", &error));
- error = NULL;
+ g_clear_error (&error);
g_assert_false (ot_util_filename_validate (".", &error));
- error = NULL;
+ g_clear_error (&error);
g_assert_false (ot_util_filename_validate ("..", &error));
+ g_clear_error (&error);
}
int main (int argc, char **argv)
static void
check_one_roundtrip (guint64 val)
{
- GString *buf = g_string_new (NULL);
+ g_autoptr(GString) buf = g_string_new (NULL);
guint64 newval;
gsize bytes_read;